var basePath="";
var startDate="";
var endDate="";
var starthour="";
var endhour="";
var starttime="";
var endtime="";
var serveid="";
var total="";
$(document).ready(function(){
	
	loadI();
	WantCalendarMonth();
	toolTip();
	pickI();
	wantGoC();
	wantS(carid,startDate,endDate,starttime,endtime,serveid);
	resI();
	expI();
	ordI();
	retract();
	wantCR();
	wantIR();
	goToOrder();
	minP(carid,startDate,endDate);
	CountRentTime();
});
//初始化全局变量
function loadI(){
	
	startDate = $("text.rentinfo_center_left_date_center_up:eq(1)").text();
	starthour = $("text.rentinfo_center_left_date_center_up:eq(2)").text();
	endDate = $("text.rentinfo_center_left_date_center_up:eq(4)").text();
	endhour = $("text.rentinfo_center_left_date_center_up:eq(5)").text();
	startdate = startDate.replace(/-/g,"/");
	enddate = endDate.replace(/-/g,"/");
	var s = startdate + " " + starthour + ":00";
	var e = enddate + " " + endhour + ":00";
	var startt = new Date(s);
	var endt = new Date(e);
	var sh = startt.getHours();
	var sm = startt.getMinutes();
	var eh = endt.getHours();
	var em = endt.getMinutes();
	if(sm == "30"){
		starttime = sh*2 + 1;
	}else{
		starttime = sh*2;
	}
	if(em == "30"){
		endtime = eh*2 + 1;
	}else{
		endtime = eh*2;
	}
	console.log("startDate="+startDate);
	console.log("starthour="+starthour);
	console.log("endDate="+endDate);
	console.log("endhour="+endhour);
	console.log("starttime="+starttime);
	console.log("endtime="+endtime);
	
}
//计算出发返程时间差
function CountRentTime(){
	var startdate = $("div.rentinfo_myinfo_item:eq(0)").text();
	var enddate = $("div.rentinfo_myinfo_item:eq(1)").text();
	var starthour = $("div.rentinfo_myinfo_item:eq(2)").text();
	var endhour = $("div.rentinfo_myinfo_item:eq(3)").text();
	startdate = startDate.replace(/-/g,"/");
	enddate = endDate.replace(/-/g,"/");
	var sd = startdate + " " + starthour + ":00";
	var ed = enddate + " " + endhour + ":00";
	//处理时间
	var stime = new Date(sd);
	var etime = new Date(ed);
	var usedTime = etime - stime;
	var days=Math.floor(usedTime/(24*3600*1000));  
    //计算出小时数  
    var leave1=usedTime%(24*3600*1000);    //计算天数后剩余的毫秒数  
    var hours=Math.floor(leave1/(3600*1000));  
    //计算相差分钟数  
    var leave2=leave1%(3600*1000);        //计算小时数后剩余的毫秒数  
    var minutes=Math.floor(leave2/(60*1000));  
	
	var up = days + "天";
	var down = hours + "小时" + minutes + "分钟";
	var counttime = "共" + up + down;
	$("div.rentinfo_center_left_date_right").text(counttime);
	
}
//启动填充tooltip工具
function toolTip(){
	$("[data-toggle='tooltip']").tooltip();
	var p0="<div class=\"rentinfo_center_right_price_detail_three_item\">租金￥<font class=\"hidden\">1000</font></div>\n" +
	"<div class=\"rentinfo_center_right_price_detail_three_item\">承租人责任险￥<font class=\"hidden\">1000</font></div>\n" +
	"<div class=\"rentinfo_center_right_price_detail_three_item\">订单取消险￥<font class=\"hidden\">1000</font></div>"
	$("a.rentinfo_center_right_price_detail_three_a").attr('title',p0).tooltip('fixTitle');
	
	var p1="1.车辆租金按小时计算，根据用户取车日期至还车日期时间进行价格计算；2.取车时间≤12点，以当天的价格为首日价格，取车时间＞12点，以翌日价格为首日价格；3.租车时间超出整天小时数≤4h，按当日价格/8 每小时计算，若＞4小时，按一天价格计费。";
	$("a.rentinfo_center_right_ser_right_one_left_a:eq(0)").attr('title',p1).tooltip('fixTitle');
	
	var p2="1.保险费用按自然日计算；2.车辆损失/全车盗抢保障50万/车，第三责任险50万/人，车上人员责任保额6万/人；3.每次事故免赔额：车辆损失事故为人民币15000元或损失金额的15%，两者以高者为准，盗抢事故为保险车辆出险时实际价值的20%";
	$("a.rentinfo_center_right_ser_right_two_left_a:eq(0)").attr('title',p2).tooltip('fixTitle');
	
	var p3="无需承担车辆发生损失的15%自费损失和发生抢盗的20%自费损失";
	$("a.rentinfo_center_right_ser_right_two_left_a:eq(1)").attr('title',p3).tooltip('fixTitle');
	
	var p4="租期开始前，被保险人因非自身原因取消订单，按照80%的比例赔付，500元/天封顶";
	$("a.rentinfo_center_right_ser_right_two_left_a:eq(2)").attr('title',p4).tooltip('fixTitle');
	
	var a1="为了您的出行方便和下一位顾客用车方便，我们尽力满箱油出车，在满油还车时，您不必支付任何燃油费用，如您还车时不便加满油，您需多支付一部分服务费用";
	$("a.rentinfo_center_right_ser_right_five_item_a:eq(0)").attr('title',a1).tooltip('fixTitle');
	
	var a2="轻松取还，不限里程";
	$("a.rentinfo_center_right_ser_right_five_item_a:eq(1)").attr('title',a2).tooltip('fixTitle');

	var a3="1.积分专属搜房车，仅限搜房车平台使用；在搜房车平台消费可以100积分=1元抵扣现金；2.积分可以累积，有效期2年，逾期自动作废（如若交易在使用的积分有效期之外发生退款，该部分积分不予退还）；3.在搜房车平台消费，均可获得积分，积分的基准返点比例为订单价格的20%；4.积分的数值精确到个位，不足1积分的数值向上取整";
	$("a.rentinfo_center_right_ser_right_five_item_a:eq(2)").attr('title',a3).tooltip('fixTitle');
	
	var a4="为保证正常出行，您需要支付房车租赁全部费用";
	$("a.rentinfo_center_right_ser_right_five_item_a:eq(3)").attr('title',a4).tooltip('fixTitle');
}
//取上个页面传过来的值
function pickI(){
	carid=$("div.rentinfo_center_left_date>input").val();
	console.log("carid="+carid);
	wantInfo(carid);
}
//根据carid查找车辆详细信息
function wantInfo(carid){
	$.ajax({		
		dataType : "json",
		type : "post",
		url : basePath+"/car/info",
		data : {
			id:carid
		},		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			$("div.rentinfo_center_right_title_up").text(data.data.title);
			$("div.rentinfo_info_left_more_detail_item_right:eq(0)").text(data.data.chassis);
			$("div.rentinfo_info_left_more_detail_item_right:eq(1)").text(data.data.brand);
			$("div.rentinfo_info_left_more_detail_item_right:eq(2)").text(data.data.transmission);
			$("div.rentinfo_info_left_more_detail_item_right:eq(3)").text(data.data.oiltype);
			$("div.rentinfo_info_left_more_detail_item_right:eq(4)").text(data.data.oilwear);
			$("div.rentinfo_info_left_more_detail_item_right:eq(5)").text(data.data.passengers);
			$("div.rentinfo_info_left_more_detail_item_right:eq(6)").text(data.data.drive);			
			if(data.data.icebox==0){
				$("img.rentinfo_info_left_more_detail_item_right_posi:eq(0)").addClass("hidden");
			};
			if(data.data.cabAircon==0){
				$("img.rentinfo_info_left_more_detail_item_right_posi:eq(1)").addClass("hidden");
			};
			if(data.data.livingAircon==0){
				$("img.rentinfo_info_left_more_detail_item_right_posi:eq(2)").addClass("hidden");
			};
			$("div.rentinfo_info_left_more_detail_item_right:eq(10)").text(data.data.equipment);
			if(data.data.cabHeating==0){
				$("img.rentinfo_info_left_more_detail_item_right_posi:eq(3)").addClass("hidden");
			};
			if(data.data.livingHeating==0){
				$("img.rentinfo_info_left_more_detail_item_right_posi:eq(4)").addClass("hidden");
			};
			$("div.rentinfo_info_left_more_detail_item_right:eq(13)").text(data.data.bed);
			$("div.rentinfo_info_left_more_detail_item:eq(14)").text(data.data.bedinfo);
			$("div.rentinfo_info_left_more_detail_item_right:eq(14)").text(data.data.oil);
			$("div.rentinfo_info_left_more_detail_item_right:eq(15)").text(data.data.water);
			$("div.rentinfo_info_left_more_detail_item_right:eq(16)").text(data.data.blackwater);
			$("div.rentinfo_info_left_more_detail_item_right:eq(17)").text(data.data.graywater);
			$("div.rentinfo_info_left_more_detail_item_right:eq(18)").text(data.data.deposite);
			$("div.rentinfo_info_left_more_detail_item_right:eq(19)").text(data.data.foregift);
			
			for(var i=1;i<data.data.photos.length;i++){
				$('.swiper-wrapper').append('<div class="swiper-slide"><img src="'+ data.data.photos[i].picture +'" width="100%"></div>')
			}
			  var galleryThumbs = new Swiper('.gallery-thumbs', {
			      spaceBetween: 10,
			      slidesPerView: 4,
			      freeMode: true,
			      watchSlidesVisibility: true,
			      watchSlidesProgress: true,
			    });
			    var galleryTop = new Swiper('.gallery-top', {
			      spaceBetween: 10,
			      navigation: {
			        nextEl: '.swiper-button-next',
			        prevEl: '.swiper-button-prev',
			      },
			      thumbs: {
			        swiper: galleryThumbs
			      }
			    });

// 			$("div.carousel-inner>div.item>img").attr("src",data.data.photos[0].picture);
// 			for(var i=1;i<data.data.photos.length;i++){
// //				var a="<li data-target=\"#banner\" data-slide-to=\""+i+"\"></li>"
// //				$("ol.carousel-indicators>li.active").after(a);
// 				var b="<div class=\"item\">\n" +
// 				"<img src=\""+data.data.photos[i].picture+"\" alt=\"First slide\" class=\"img-responsive\" />\n" +
// 				"<div class=\"carousel-caption\" ></div>\n" +
// 				"</div>"
// 				$("div.carousel-inner>div.active").after(b);
// 			}
			//设置title
			$(document).attr("title",data.data.title);//修改title值  
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			console.log("请求完成");
		},
	});
}
//初始请求取车时间那个月的价格日历
function wantGoC(){
	var time=$("text.rentinfo_center_left_date_center_up:eq(1)").text();
	var a=time.split(" ")[0];
	var b=parseInt(a.split("-")[1]);//取出时间月的部分
	var c=parseInt(a.split("-")[2]);//取出时间日的部分
	var d=a.split("-")[0]//取出时间年部分，为String
	var carid=$("div.rentinfo_center_left_date>input").val();
	var year=d;
	var month=b;
	wantC(carid,year,month);
}
//绑定点击请求价格日历
function wantCa(){
	var carid=$("div.rentinfo_center_left_date>input").val();
	for(var i=0;i<12;i++){
		$("div.rentinfo_center_left_cal_top_item:eq("+i+")").click(function(i){
			return function(){
				$(this).addClass("rentinfo_center_left_cal_top_itemchoose");
				$("div.rentinfo_center_left_cal_top>div").not(this).removeClass("rentinfo_center_left_cal_top_itemchoose");
				var time = $("div.rentinfo_center_left_cal_top_item:eq("+i+")").text();
				var year = time.split("-")[0];
				var month = time.split("-")[1];
				wantC(carid,year,month);
				console.log("carid="+carid);
				console.log("year="+year);
				console.log("month="+month);
			}		
		}(i))
	}
}
//请求价格日历
function wantC(carid,year,month){
	LoadingIcon = layer.load();
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/dateprice",
		data : {
			id:carid,
			year:year,
			month:month
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var c="";
			for (var i = 0; i < data.data.length; i++) {
				if(data.data[i].price==""){
					c = c+
					"<div class=\"rentinfo_center_left_cal_down_item\">\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_date clearfix\">\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_date_one\">"+data.data[i].date+"</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_date_one\"></div>\n" +
					"</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price clearfix hidden\">\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price_one\">起</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price_two\">"+data.data[i].price+"</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price_three\">￥</div>\n" +
					"</div>\n" +
					"</div>"
				}else{
					c = c+
					"<div class=\"rentinfo_center_left_cal_down_item\">\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_date clearfix\">\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_date_one\">"+data.data[i].date+"</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_date_one\"></div>\n" +
					"</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price clearfix\">\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price_one\">起</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price_two\">"+data.data[i].price+"</div>\n" +
					"<div class=\"rentinfo_center_left_cal_down_item_price_three\">￥</div>\n" +
					"</div>\n" +
					"</div>"
				}
			};
			$("div.rentinfo_center_left_cal_down").html(c);
			console.log("carid="+carid);
			console.log("year="+year);
			console.log("month="+month);
			//因价格日历请求所需时间最长，所以将滚动条动作放于此
			knowM();
			
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			layer.close(LoadingIcon);
		},
	});
}
//请求服务价格
function wantS(carid,startDate,endDate,starttime,endtime,serveid){
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/priceinfo",
		data : {
			id:carid,
			startDate:startDate,
			endDate:endDate,
			starttime:starttime,
			endtime:endtime,
			serveid:serveid,
		},		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var p="";
			var x="";
			var t=0;
			for(var i=0;i<data.data.length;i++){
				p=p+"<div class=\"rentinfo_center_right_price_detail_three_item\">"+data.data[i].serve+"￥<font class=\"hidden\">"+data.data[i].price+"</font></div>\n";
				t=t+data.data[i].price;
			}
			for(var i=0;i<data.data.length;i++){
				x=x+
				"<div class=\"rentinfo_info_right_item_two clearfix\">\n" +
				"<div class=\"rentinfo_info_right_item_two_one\">"+data.data[i].serve+"</div>\n" +
				"<div class=\"rentinfo_info_right_item_two_two\">"+data.data[i].price+"</div>\n" +
				"<div class=\"rentinfo_info_right_item_two_three\">￥</div>\n" +
				"</div>"
			};
			
			$("div.rentinfo_info_right_item_oneafter").html(x);
			$("a.rentinfo_center_right_price_detail_three_a").attr('title',p).tooltip('fixTitle');
			total=t;
			$("div.rentinfo_center_right_price_detail_two").text(t);
			$("div.rentinfo_info_right_item_one_two").text(t);
			console.log("serveid="+serveid)
			
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			
		},
	});
}
//根据旅客时间选择请求每日最低价格
function minP(carid,startDate,endDate){
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/minprice",
		data : {
			carid:carid,
			startDate:startDate,
			endDate:endDate,
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			console.log(data.data.minprice)
			$("div.rentinfo_center_right_ser_right_one_right_two").text(data.data.minprice);
			
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			
		},
	});
}
//承租人责任险绑定事件
var resI = function(){
	$("div.rentinfo_center_right_ser_right_two").click(function(){
		var array = serveid.split("|");
		console.log("array="+array);
		if(array == "" || array.length == 0){
			serveid = "|8";
			$("div.rentinfo_center_right_ser_right_two").addClass("rentinfo_center_right_ser_right_twochoose");
			$("div.rentinfo_center_right_ser_right_one_icon:eq(1)").removeClass("hidden");
			wantS(carid,startDate,endDate,starttime,endtime,serveid);
			console.log("serveid="+serveid);
		}else{
			if(array.indexOf("6") > -1){				
				$("div.rentinfo_center_right_ser_right_three").removeClass("rentinfo_center_right_ser_right_three_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(2)").addClass("hidden");
			};
			if(array.indexOf("7") > -1){				
				$("div.rentinfo_center_right_ser_right_four").removeClass("rentinfo_center_right_ser_right_four_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(3)").addClass("hidden");
			};
			serveid = "";
			$("div.rentinfo_center_right_ser_right_two").removeClass("rentinfo_center_right_ser_right_twochoose");
			$("div.rentinfo_center_right_ser_right_one_icon:eq(1)").addClass("hidden");
			wantS(carid,startDate,endDate,starttime,endtime,serveid);
			console.log("serveid="+serveid);
		};
	});
}
//不计免赔险绑定事件
function expI(){
	$("div.rentinfo_center_right_ser_right_three").click(function(){
		var array = serveid.split("|");
		if(array == "" || array.length == 0){
			serveid = "6|8";
			$("div.rentinfo_center_right_ser_right_three").addClass("rentinfo_center_right_ser_right_three_choose");
			$("div.rentinfo_center_right_ser_right_one_icon:eq(2)").removeClass("hidden");
			$("div.rentinfo_center_right_ser_right_two").addClass("rentinfo_center_right_ser_right_twochoose");
			$("div.rentinfo_center_right_ser_right_one_icon:eq(1)").removeClass("hidden");
			wantS(carid,startDate,endDate,starttime,endtime,serveid);
			console.log("serveid="+serveid);
		}else{
			if((array.indexOf("6") > -1)&&(array.indexOf("7") > -1)){
				serveid = "7|8";
				$("div.rentinfo_center_right_ser_right_three").removeClass("rentinfo_center_right_ser_right_three_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(2)").addClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			};
			if((array.indexOf("6") > -1)&&(array.indexOf("7") == -1)){
				serveid = "|8";
				$("div.rentinfo_center_right_ser_right_three").removeClass("rentinfo_center_right_ser_right_three_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(2)").addClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			};
			if((array.indexOf("7") > -1)&&(array.indexOf("6") == -1)){
				serveid = "6|7|8";
				$("div.rentinfo_center_right_ser_right_three").addClass("rentinfo_center_right_ser_right_three_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(2)").removeClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			};
			if(array.indexOf("8") > -1){
				serveid = "6|8";
				$("div.rentinfo_center_right_ser_right_three").addClass("rentinfo_center_right_ser_right_three_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(2)").removeClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			}
		}
		
	})
}
//订单损失险绑定事件
function ordI(){
	$("div.rentinfo_center_right_ser_right_four").click(function(){
		var array = serveid.split("|");
		if(array == "" || array.length == 0){
			serveid = "7|8";
			$("div.rentinfo_center_right_ser_right_four").addClass("rentinfo_center_right_ser_right_four_choose");
			$("div.rentinfo_center_right_ser_right_one_icon:eq(3)").removeClass("hidden");
			$("div.rentinfo_center_right_ser_right_two").addClass("rentinfo_center_right_ser_right_twochoose");
			$("div.rentinfo_center_right_ser_right_one_icon:eq(1)").removeClass("hidden");
			wantS(carid,startDate,endDate,starttime,endtime,serveid);
			console.log("serveid="+serveid);
		}else{
			if((array.indexOf("6") > -1)&&(array.indexOf("7") > -1)){
				serveid = "6|8";
				$("div.rentinfo_center_right_ser_right_four").removeClass("rentinfo_center_right_ser_right_four_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(3)").addClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			};
			if((array.indexOf("6") > -1)&&(array.indexOf("7") == -1)){
				serveid = "6|7|8";
				$("div.rentinfo_center_right_ser_right_four").addClass("rentinfo_center_right_ser_right_four_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(3)").removeClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			};
			if((array.indexOf("7") > -1)&&(array.indexOf("6") == -1)){
				serveid = "|8";
				$("div.rentinfo_center_right_ser_right_four").removeClass("rentinfo_center_right_ser_right_four_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(3)").addClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			};
			if(array.indexOf("8") > -1){
				serveid = "7|8";
				$("div.rentinfo_center_right_ser_right_four").addClass("rentinfo_center_right_ser_right_four_choose");
				$("div.rentinfo_center_right_ser_right_one_icon:eq(3)").removeClass("hidden");
				wantS(carid,startDate,endDate,starttime,endtime,serveid);
				console.log("serveid="+serveid);
				return;
			}
		}
		
	})
}
//绑定车辆配置中收起的动作绑定
function retract(){
	for(var i=0;i<4;i++){
		$("div.rentinfo_info_left_more_title_right:eq("+i+")").click(function(i){
			return function(){
				$("div.rentinfo_info_left_more_detail:eq("+i+")").fadeToggle();
				var word = ($(this).text()=="收起∧"?"展开v":"收起∧");
				$(this).text(word);
			}			
		}(i))
	}
	//点击车辆配置，车辆详情，租车须知
	$("div.rentinfo_info_left_top_item:eq(0)").click(function(){
		// $("div.rentinfo_info_left_top_item").removeClass("rentinfo_info_left_top_itemchoose");
		// $(this).addClass("rentinfo_info_left_top_itemchoose");
		window.location.hash = "#cardetailequip";
	});
	$("div.rentinfo_info_left_top_item:eq(1)").click(function(){
		// $("div.rentinfo_info_left_top_item").removeClass("rentinfo_info_left_top_itemchoose");
		// $(this).addClass("rentinfo_info_left_top_itemchoose");
		window.location.hash = "#cardetailinfo";
	});
	$("div.rentinfo_info_left_top_item:eq(2)").click(function(){
		// $("div.rentinfo_info_left_top_item").removeClass("rentinfo_info_left_top_itemchoose");
		// $(this).addClass("rentinfo_info_left_top_itemchoose");
		window.location.hash = "#cardetailknow";
		
	});
}
//请求车辆详情富文本
function wantCR(){
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/detailinfo",
		data : {
			id:carid,
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var p="";
			for(var i=0;i<data.data.length;i++){
				p=p+
				"<div class=\"rentinfo_info_left_detail_img\">\n"+
				"<img src=\""+data.data[i].detail+"\" class=\"rentinfo_info_left_detail_img_posi\">\n"+
				"</div>\n";				
			};
			$("div.rentinfo_info_left_detail").html(p);
			
			
			
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			
		},
	});
}
//请求租车须知富文本
function wantIR(){
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/preinfo",
		data : {
			id:carid,
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var p="";
			var c="";
			for(var i=0;i<data.data.length;i++){
				p=p+
				"<pre class=\"rentinfo_info_left_ins_item\">"+data.data[i].detail+"</pre>";
				c = c + data.data[i].detail;
			};
			console.log("c="+c);
			$("div.rentinfo_info_left_ins").html(p);
			
			
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			
		},
	});
}
//绑定车辆配置 车辆详情 保险说明点击事件
function knowM(){
	var win = $(window);
	var sc = $(document);
	var ht = $("div.rentinfo_info_left_detailall").outerHeight();

	var cardetailequip = $('#cardetailequip').position().top - 152
	var cardetailinfo = $('#cardetailinfo').position().top - 152
	var cardetailknow = $('#cardetailknow').position().top - 152
	var winHeight = win.height()

	
	win.scroll(function(){
		
		var height = win.scrollTop()

		if(height < cardetailequip){
			$("div.rentinfo_info_left_top").removeClass("rentinfo_info_left_top_itemfix");
			$("div.rentinfo_info_right_item").removeClass("rentinfo_info_right_itemfix");
			
		}else{
			$("div.rentinfo_info_left_top").addClass("rentinfo_info_left_top_itemfix");
			$("div.rentinfo_info_right_item").addClass("rentinfo_info_right_itemfix");
		}

		if(height >= cardetailequip && height < cardetailinfo ){
			
			$("div.rentinfo_info_left_top_item:eq(0)").addClass("rentinfo_info_left_top_itemchoose");
			$("div.rentinfo_info_left_top_item:eq(1)").removeClass("rentinfo_info_left_top_itemchoose");
			$("div.rentinfo_info_left_top_item:eq(2)").removeClass("rentinfo_info_left_top_itemchoose");
		}

		if(height >= cardetailinfo && height < cardetailknow){
			console.log("length="+sc.scrollTop());
			$("div.rentinfo_info_left_top_item:eq(0)").removeClass("rentinfo_info_left_top_itemchoose");
			$("div.rentinfo_info_left_top_item:eq(1)").addClass("rentinfo_info_left_top_itemchoose");
			$("div.rentinfo_info_left_top_item:eq(2)").removeClass("rentinfo_info_left_top_itemchoose");
			
		}
		if(height >= cardetailknow){
			console.log("length="+sc.scrollTop());
			$("div.rentinfo_info_left_top_item:eq(0)").removeClass("rentinfo_info_left_top_itemchoose");
			$("div.rentinfo_info_left_top_item:eq(1)").removeClass("rentinfo_info_left_top_itemchoose");
			$("div.rentinfo_info_left_top_item:eq(2)").addClass("rentinfo_info_left_top_itemchoose");
		}
		
	});
}
//绑定跳转租车填写订单页
function goToOrder(){
	$("div.rentinfo_center_right_order>input").click(function(){
		
		
			Rserveid = serveid.replace(/|/g,"-");
			url = basePath+"/rentorder?serviceid="+Rserveid;
			url  = encodeURI(url);
			url  = encodeURI(url);
			window.location.href = (url);	
	});
	$("input.rentinfo_info_right_item_four_b").click(function(){
		
		
			Rserveid = serveid.replace(/|/g,"-");
			window.location.href = (basePath+"/rentorder?serviceid="+Rserveid);
		
	})
}
//初始化可选择价格日历月份的值
function WantCalendarMonth(){
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/rentinfogivemonth",
		data : {
			
		},	
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var m = "";
			for(var i=0;i<data.data.length;i++){
				m = m + "<div class=\"rentinfo_center_left_cal_top_item\">"+data.data[i].month+"</div>"
			};
			$("div.rentinfo_center_left_cal_top").html(m);
			$("div.rentinfo_center_left_cal_top_item:eq(0)").addClass("rentinfo_center_left_cal_top_itemchoose");
			wantCa();
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			
		},
	});
}